﻿package mortal.game.view.mainUI.Navbar
{
    import com.greensock.*;
    import com.greensock.easing.*;
    import flash.display.*;
    import flash.geom.*;

    public class NavbarShakerItem extends Object
    {
        private var _shakeTarget:DisplayObject;
        private var _shakePoint:Point;
        private var _shakeTween1:TweenMax;
        private var _shakeTween2:TweenMax;
        private var _time:Number = 0.13;

        public function NavbarShakerItem()
        {
            this._shakePoint = new Point();
            return;
        }// end function

        public function shake(param1:DisplayObject, param2:int, param3:int, param4:Number = -1) : void
        {
            this._shakeTarget = param1;
            this._shakePoint.x = param2;
            this._shakePoint.y = param3;
            if (param4 > 0)
            {
                this._shakeTween1 = TweenMax.to(this._shakeTarget, this._time, {y:this._shakePoint.y + 14, onComplete:this.tween1complete, delay:param4});
            }
            else
            {
                this._shakeTween1 = TweenMax.to(this._shakeTarget, this._time, {y:this._shakePoint.y + 14, onComplete:this.tween1complete});
            }
            return;
        }// end function

        private function tween1complete() : void
        {
            this._shakeTween1 = null;
            this._shakeTween2 = TweenMax.to(this._shakeTarget, 0.08, {y:this._shakePoint.y, onComplete:this.tween2complete, ease:Linear.easeOut});
            return;
        }// end function

        private function tween2complete() : void
        {
            this._shakeTween2 = null;
            this._shakeTarget = null;
            NavbarShaker.instance.inPool(this);
            return;
        }// end function

    }
}
